home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / Speech.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  8.2 KB  |  281 lines  |  [TEXT/MPS ]

  1.  
  2. Unit Speech;
  3. Interface
  4.  
  5. Uses
  6.     MemTypes,
  7.     OSIntf,
  8.     ToolIntf,
  9.     SysEqu,
  10.     Components;
  11.  
  12.  
  13. CONST
  14.  
  15.     gestaltSpeechAttr = 'ttsc';        { Gestalt Manager selector for Speech Attributes }
  16.     gestaltSpeechMgrPresent = 0;    { Gestalt bit which indicates that Speech Manager exists }
  17.  
  18.  
  19. kTextToSpeechSynthType         = 'ttsc';    { Text-to-Speech Synthesizer component type     }
  20. kTextToSpeechVoiceType         = 'ttvd';    { Text-to-Speech Voice resource type             }
  21. kTextToSpeechVoiceFileType     = 'ttvf';    { Text-to-Speech Voice file type                 }
  22. kTextToSpeechVoiceBundleType = 'ttvb';    { Text-to-Speech Voice Bundle file type            }
  23.  
  24.     { Speech Manager error codes (Range from 240 - 259) }
  25.     
  26.     noSynthFound         = -240;
  27.     synthOpenFailed     = -241;
  28.     synthNotReady        = -242;
  29.     bufTooSmall         = -243;
  30.     voiceNotFound        = -244;
  31.     incompatibleVoice    = -245;
  32.     badDictFormat         = -246;
  33.  
  34.         
  35.     { constants for SpeakBuffer and TextDone callback controlFlags bits }
  36.     
  37.     kNoEndingProsody     = 1;
  38.     kNoSpeechInterrupt     = 2;
  39.     kPreflightThenPause    = 4;    
  40.     
  41.     
  42.     { constants for StopSpeechAt and PauseSpeechAt }
  43.     
  44.     kImmediate        = 0;
  45.     kEndOfWord        = 1;
  46.     kEndOfSentence    = 2;
  47.     
  48.     
  49.     
  50.     { GetSpeechInfo & SetSpeechInfo selectors }
  51.     
  52.     soStatus                = 'stat';
  53.     soErrors                = 'erro';
  54.     soInputMode                = 'inpt';
  55.     soCharacterMode            = 'char';
  56.     soNumberMode            = 'nmbr';
  57.     soRate                    = 'rate';
  58.     soPitchBase                = 'pbas';
  59.     soPitchMod                = 'pmod';
  60.     soVolume                = 'volm';
  61.     soSynthType                = 'vers';
  62.     soRecentSync            = 'sync';
  63.     soPhonemeSymbols        = 'phsy';
  64.     soCurrentVoice            = 'cvox';
  65.     soCommandDelimiter        = 'dlim';
  66.     soReset                    = 'rset';
  67.     soCurrentA5                = 'myA5';
  68.     soRefCon                = 'refc';
  69.     soTextDoneCallBack        = 'tdcb';
  70.     soSpeechDoneCallBack    = 'sdcb';
  71.     soSyncCallBack            = 'sycb';
  72.     soErrorCallBack            = 'ercb';
  73.     soPhonemeCallBack        = 'phcb';
  74.     soWordCallBack            = 'wdcb';
  75.     soSynthExtension        = 'xtnd';
  76.  
  77.  
  78.     { Speaking Mode Constants }
  79.  
  80.     modeText        = 'TEXT';        { input mode constants     }
  81.     modeTX            = 'TX';
  82.     modePhonemes    = 'PHON';
  83.     modePH            = 'PH';
  84.     modeNormal        = 'NORM';        { character mode and number mode constants }
  85.     modeLiteral        = 'LTRL';
  86.  
  87.     { GetVoiceInfo selectors }
  88.     
  89.     soVoiceDescription    = 'info';    { gets basic voice info }
  90.     soVoiceFile            = 'fref';    { gets voice file ref info }
  91.  
  92.  
  93.     kNeuter     = 0;
  94.     kMale        = 1;
  95.     kFemale        = 2;
  96.  
  97.  
  98.  
  99.  
  100. TYPE
  101.  
  102.     SpeechChannelRecord = Longint;
  103.     SpeechChannel = ^SpeechChannelRecord;
  104.     SpeechChannelPtr = ^SpeechChannel;
  105.  
  106.  
  107.     VoiceSpec =
  108.         RECORD
  109.             creator:    OSType;            { creator id of required synthesizer     }
  110.             id:            OSType;            { voice id on the specified synth         }
  111.         END;
  112.     VoiceSpecPtr = ^VoiceSpec;
  113.  
  114.  
  115.     VoiceDescription =
  116.         RECORD
  117.             length:        Longint;                { size of structure - set by application     }
  118.             voice:        VoiceSpec;                { voice creator and id info             }
  119.             version:    Longint;                { version code for voice                 }
  120.             name:        Str63;                    { name of voice                         }
  121.             comment:    Str255;                    { additional text info about voice         }
  122.             gender:        Integer;                { neuter, male, or female                }
  123.             age:        Integer;                { approximate age in years                 }
  124.             script:        Integer;                { script code of text voice can process }
  125.             language:    Integer;                { language code of voice output speech     }
  126.             region:        Integer;                { region code of voice output speech     }
  127.             reserved1:    Longint;                { always zero - reserved for future use    }
  128.             reserved2:    Longint;                { always zero - reserved for future use    }
  129.             reserved3:    Longint;                { always zero - reserved for future use    }
  130.             reserved4:    Longint;                { always zero - reserved for future use    }
  131.         END;
  132.     VoiceDescriptionPtr = ^VoiceDescription;
  133.  
  134.     VoiceFileInfo =
  135.         RECORD
  136.             fileSpec:    FSSpec;                    { volume, dir, & name information for voice file }
  137.             resID:        Integer;                { resource id of voice in the file }
  138.         END;
  139.     VoiceFileInfoPtr = ^VoiceFileInfo;
  140.  
  141.  
  142.  
  143.     SpeechStatusInfo = 
  144.         RECORD
  145.             outputBusy:        Boolean; { TRUE if audio is playing}
  146.             outputPaused:    Boolean; { TRUE if channel is paused}
  147.             inputBytesLeft:    Longint; { bytes of input left to process}
  148.             phonemeCode:    Integer; { code for current phoneme}
  149.         END;
  150.     SpeechStatusInfoPtr = ^SpeechStatusInfo;
  151.     
  152.     
  153.     
  154.     
  155.     SpeechModeInfo = 
  156.         RECORD
  157.             inputMode:        OSType;    {'TEXT' or 'PHON'}
  158.             characterMode:    OSType;    {'NORM' or 'LTRL'}
  159.             numberMode:        OSType;    {'NORM' or 'LTRL'}
  160.             symbolMode:        OSTYpe;    {'NORM' or 'LTRL'}
  161.         END;
  162.     SpeechModeInfoPtr = ^SpeechModeInfo;
  163.     
  164.     
  165.     SpeechVersionInfo = 
  166.         RECORD
  167.             synthType:            OSType;            { always ‘ttsc’ }
  168.             synthSubType:        OSType;            { Flavor of synth }
  169.             synthManufacturer:    OSType;            { synth creator ID }
  170.             synthFlags:            Longint;        { synth feature flags }
  171.             synthVersion:        NumVersion;     { synth version number }
  172.         END;
  173.     SpeechVersionInfoPtr = ^SpeechVersionInfo;
  174.     
  175.     
  176.     TYPE speechXtndData = 
  177.         RECORD
  178.             synthCreator:    OSType;                        {synthesizer ID selector}
  179.             synthData:        PACKED ARRAY [0..1] of Char;{ data bytes TBD by synthesizer }
  180.         END;
  181.     
  182.     DelimiterInfo =
  183.         RECORD
  184.             startDelimiter:    PACKED ARRAY [0..1] of Char;
  185.             endDelimiter:    PACKED ARRAY [0..1] of Char;
  186.         END;
  187.     
  188.  
  189.     SpeechErrorInfo =
  190.         RECORD
  191.             count:        Integer;            { # of errs since last check         }
  192.             oldest:        OSErr;                { oldest unread error                 }
  193.             oldPos:        Longint;            { char position of oldest err         }
  194.             newest:        OSErr;                { most recent error                 }
  195.             newPos:        Longint;            { char position of newest err         }
  196.         END;
  197.  
  198.  
  199.     PhonemeInfo =
  200.         RECORD
  201.             opcode:            Integer;        { opcode for the phoneme             }
  202.             phStr:            Str15;            { corresponding char string         }
  203.             exampleStr:        Str31;            { word that shows use of phoneme     }
  204.             hiliteStart:    Integer;        { segment of example word that         }
  205.             hiliteEnd:        Integer;        { should be hilighted (ala TextEdit) }
  206.         END;
  207.  
  208.     PhonemeDescriptor =
  209.         RECORD
  210.             phonemeCount:    Integer;                         { # of elements         }
  211.             thePhonemes:    ARRAY [0..0] of PhonemeInfo;     { element list         }
  212.         END;
  213.  
  214.  
  215.  
  216. FUNCTION  SpeechManagerVersion: NumVersion;
  217.     INLINE $203C,$0000,$000C,$A800;
  218.  
  219. FUNCTION  MakeVoiceSpec ( creator: OSType; id: OSType; voice: VoiceSpecPtr): OSErr;
  220.     INLINE $203C, $0604, $000C, $A800;
  221. FUNCTION CountVoices (numVoices: IntegerPtr): OSErr;
  222.     INLINE $203C, $0108, $000C, $A800;
  223. FUNCTION GetIndVoice (index: Integer; voice: VoiceSpecPtr): OSErr;
  224.     INLINE $203C, $030C, $000C, $A800;
  225. FUNCTION GetVoiceDescription (voice: VoiceSpecPtr; info: VoiceDescriptionPtr; infoLength: Longint): OSErr;
  226.     INLINE $203C, $0610, $000C, $A800;
  227. FUNCTION GetVoiceInfo (voice: VoiceSpecPtr; selector: OSType; voiceInfo: Ptr): OSErr;
  228.     INLINE $203C, $0614, $000C, $A800;
  229.  
  230. FUNCTION StopSpeech (chan: SpeechChannel): OSErr;
  231.     INLINE $203C, $022C, $000C, $A800;
  232.  
  233. FUNCTION SetSpeechRate (chan: SpeechChannel; rate: Fixed): OSErr;
  234.     INLINE $203C, $0444, $000C, $A800;
  235. FUNCTION GetSpeechRate (chan: SpeechChannel; rate: FixedPtr): OSErr;
  236.     INLINE $203C, $0448, $000C, $A800;
  237. FUNCTION SetSpeechPitch (chan: SpeechChannel; pitch: Fixed): OSErr;
  238.     INLINE $203C, $044C, $000C, $A800;
  239. FUNCTION GetSpeechPitch (chan: SpeechChannel; pitch: FixedPtr): OSErr;
  240.     INLINE $203C, $0450, $000C, $A800;
  241.  
  242. FUNCTION UseDictionary (chan: SpeechChannel; dictionary: Handle): OSErr;
  243.     INLINE $203C, $0460, $000C, $A800;
  244.     
  245.  
  246.     
  247. FUNCTION  NewSpeechChannel( voice: VoiceSpecPtr; chanPtr: SpeechChannelPtr): OSErr;
  248.     INLINE $203C, $0418, $000C,$A800;
  249. FUNCTION  DisposeSpeechChannel( chan: SpeechChannel): OSErr;
  250.     INLINE $203C, $021C, $000C,$A800;
  251.  
  252. FUNCTION  SpeakString( s: Str255): OSErr;
  253.     INLINE $203C, $0220, $000C,$A800;
  254. FUNCTION  SpeakText( chan: SpeechChannel; textBuf: Ptr; byteLen: LongInt): OSErr;
  255.     INLINE $203C, $0624, $000C,$A800;
  256. FUNCTION  SpeakBuffer( chan: SpeechChannel; textBuf: Ptr; byteLen: LongInt; controlFlags: LongInt ): OSErr;
  257.     INLINE $203C, $0828, $000C,$A800;
  258.  
  259. FUNCTION  StopSpeechAt (chan: SpeechChannel; whereToStop: LongInt) : OSErr;
  260.     INLINE $203C, $0430, $000C,$A800;
  261. FUNCTION  PauseSpeechAt (chan: SpeechChannel; whereToPause: LongInt) : OSErr;
  262.     INLINE $203C, $0434, $000C,$A800;
  263. FUNCTION  ContinueSpeech (chan: SpeechChannel) : OSErr;
  264.     INLINE $203C, $0238, $000C,$A800;
  265.  
  266. FUNCTION  SpeechBusy: Integer;
  267.     INLINE $203C, $003C, $000C,$A800;
  268. FUNCTION  SpeechBusySystemWide: Integer;
  269.     INLINE $203C, $0040, $000C,$A800;
  270.  
  271. FUNCTION  GetSpeechInfo (chan: SpeechChannel; selector: OSType; speechInfo: Ptr) : OSErr;
  272.     INLINE $203C, $0658, $000C,$A800;
  273. FUNCTION  SetSpeechInfo (chan: SpeechChannel; selector: OSType; speechInfo: Ptr) : OSErr;
  274.     INLINE $203C, $0654, $000C,$A800;
  275.  
  276. FUNCTION  TextToPhonemes (chan: SpeechChannel; textBuf: Ptr; textBytes: LongInt; phonemeBuf: Handle; phonemeBytes: LongIntPtr) : OSErr;
  277.     INLINE $203C, $0A5C, $000C,$A800;
  278.  
  279. END.
  280.  
  281.